<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>十六进制转十进制</title>
</head>
<body>
<script type="application/javascript">
    // 0123456789ABCDEF
    function Num16To10 (numStr) {
      let array = numStr.split('').reverse()
      let res = 0
      array.forEach((item, index) => {
        let num = 0
        switch (item.toUpperCase()) {
          case 'A':
            num = 10
            break
          case 'B':
            num = 11
            break
          case 'C':
            num = 12
            break
          case 'D':
            num = 13
            break
          case 'E':
            num = 14
            break
          case 'F':
          case 'f':
            num = 15
            break
          default:
            num = parseInt(item)
            break
        }
        res += num * Math.pow(16, index)
      })
      return res
    }
    console.log(Num16To10('1E'))
</script>
</body>
</html>
